#include "cb_cipher.h"

int CCompositeBlockCipher::Encrypt(BYTE *pKey, int iKeyLen, BYTE *pIV, int iIVLen, BYTE *pIn, int iLenIn, BYTE *pOut, int *piLenOut)
{
    m_pobjKernel->SetKey(pKey, iKeyLen);
    m_pobjMode->SetIV(pIV, iIVLen);
    m_pobjMode->Encrypt(pIn, iLenIn, pOut, piLenOut, m_pobjKernel);
    m_pobjMode->GetIV(pIV);
    return 0;
}

int CCompositeBlockCipher::Decrypt(BYTE *pKey, int iKeyLen, BYTE *pIV, int iIVLen, BYTE *pIn, int iLenIn, BYTE *pOut, int *piLenOut)
{
    m_pobjKernel->SetKey(pKey, iKeyLen);
    m_pobjMode->SetIV(pIV, iIVLen);
    m_pobjMode->Decrypt(pIn, iLenIn, pOut, piLenOut, m_pobjKernel);
    m_pobjMode->GetIV(pIV);
    return 0;
}
